usedHoursPromptProto = {
    confirmLimit : 7
    ,initComponent : function()
    {
        this.title = 'Book working hours ticket #'+this.ticketID;
        this.items = [this.contentItems];
        usedHoursPrompt.superclass.initComponent.call(this);
        this.initHandlers();
        this.initFields();
    }
    ,initFields : function()
    {
        usedTime = [
            this.ticket.ticketData.usedTime
            , ' / '
            , this.ticket.ticketData.originalEstimate
            ,' h'
        ].join('');
        
        this.hourForm.usedTimeField.setValue(usedTime);
        this.hourForm.ticketIdField.setValue(this.ticketID);
        this.hourForm.hourField.focus(true, 1000);
    }
    ,initHandlers : function()
    {
        globals.bindHandlers(this.id, {
          saveButton : {item : this.hourForm.saveButton, fn: this.checkForSave, scope: this}
          ,cancelButton : {item : this.hourForm.cancelButton, fn: this.close, scope: this}
        });
        this.hourForm.on('afterrender', this.initKeys, this);
    }
    ,initKeys : function ()
    {
        keyMap = new Ext.KeyMap(this.hourForm.el, [
            {key: [10, 13], fn: this.doSave, scope : this}
        ])
    }
    
    ,checkForSave : function()
    {
        if(this.hourForm.hourField.getValue() > this.confirmLimit)
        {
            Ext.MessageBox.confirm(
                'Booking working hours'
                , ['You booked ',this.hourForm.hourField.getValue(),' hours.<br />Are You sure?'].join('')
                , this.confirmSave
                , this
            );
        }
        else
            this.doSave();
    }
    , confirmSave : function(button)
    {
        if(button == 'yes') this.doSave();
    }
    ,doSave : function()
    {
        console.log(this,this.hourForm.getForm());
        this.hourForm.getForm().submit({
           submitEmptyText : false
           ,success: this.afterSave
           ,failure : sweatShop.globals.formSubmitFailed
           ,scope : this
        });
    }
    ,afterSave : function(form, action)
    {
        sweatShop.log(action.result.message, 1);
        this.ticket.addBookedHoursToTicket(action.result.hours);
        this.ticket.addCommentToTicket(action.result.comment);
        this.ticket.el.highlight();
        this.close();
    }
};
usedHoursPrompt = Ext.extend(usedHoursPromptUi, usedHoursPromptProto);
Ext.reg('hourprompt', usedHoursPrompt);